package com.redteam.data.dao.interfaces;

import java.sql.*;
import java.util.List;

/**
 * Contains DAO interface methods
 * @author Steven Lawton
 * @author Jezreel Wilson
 */
public interface DAO {

    /**
     * Returns a single <code>Object</code> from the database from its reference
     *
     * @param obj the <code>Object</code> to return
     * @return the single <code>Object</code> with matching ID (if it exists)
     * @throws SQLException
     */
    Object getSingle(Object obj) throws SQLException;

    /**
     * Gets single <code>Object</code> specific to the discriminator
     * @param id
     * ID of the <code>Object</code> to return
     * @param discriminator
     * Discriminator of the <code>Object</code> to return
     * @return
     * the single <code>Object</code> with matching ID and discriminator(if it exists)
     * @throws SQLException
     */
    Object getSingle(long id, String descriminator) throws SQLException;

    /**
     * Returns a single <code>Object</code> from the database with specified ID
     *
     * @param id ID of the <code>Object</code> to return
     * @return the single <code>Object</code> with matching ID (if it exists)
     * @throws SQLException
     */
    Object getSingle(long id) throws SQLException;

    /**
     * Removes a row matching provided <code>Object</code> from the appropriate table in the database
     *
     * @param obj <code>Object</code> to remove from database
     * @return number of rows affected (will be 0 or 1)
     * @throws SQLException
     */
    int remove(Object obj) throws SQLException;

    /**
     * Removes a row from the appropriate table in the database by its specified ID
     *
     * @param id the ID of the <code>Object</code> to remove from the database
     * @return number of rows affected (will be 0 or 1 in this method)
     * @throws SQLException
     */
    int remove(long id) throws SQLException;

    /**
     * Removes all <code>Object<code>s provided by child DAO from their appropriate table(s)
     *
     * @param objs all <code>Object<code>s to remove
     * @return number of rows affected by the remove operation
     * @throws SQLException
     */
    int removeMany(List<Object> objs) throws SQLException;

    /**
     *
     * @param obj
     * @return
     * @throws SQLException
     */
    int insert(Object obj) throws SQLException;

    /**
     * Inserts all Objects provided by child DAO into their appropriate table(s)
     *
     * @param objects
     * List of <code>Objects to insert into database
     * @return number of rows affected by the insert operation
     * @throws SQLException
     */
    int insertMany(List<Object> objs) throws SQLException;

    /**
     * Updates the database with the attributes of the provided <code>Object</code>
     *
     * @param objectToUpdate the <code>Object</code> to update in the database
     * @return number of rows affected (0 or 1)
     */
    int update(Object obj) throws SQLException;

    /**
     * Returns all <code>Object</code>s in the database
     *
     * @return all <code>Object</code>s found
     * @throws SQLException
     */
    List<Object> getAll() throws SQLException;

    /**
     * Returns all <code>Object</code>s in the database
     *
     * @return all <code>Object</code>s found
     * @throws SQLException
     */
    List<Object> getAll(String discriminator) throws SQLException;
}
